package de.tu_darmstadt.gdi1.xcom.model.elements;

import de.tu_darmstadt.gdi1.framework.utils.Point;

public enum DirectionEnum {

	North(38), South(40), West(37), East(39);
	private int key;
	private char c;
	
	private DirectionEnum(int key){
		this.key = key;
		switch(key){
			case 38: c = 'n';break;
			case 40: c = 's';break;
			case 37: c = 'w';break;
			case 39: c = 'e';break;
		}
	}
	
	public int getKey(){
		return key;
	}
	
	public char getChar(){
		return c;
	}
	
	public Point getStep(){
		switch(this){
			case North: return new Point(0, -1);
			case South: return new Point(0, 1);
			case West: return new Point(-1, 0);
			case East: return new Point(1, 0);
		}
		return new Point(0,0);
	}
	
	public static DirectionEnum getDirectionFromKey(int key){
		switch(key){
			case 38: return North;
			case 40: return South;
			case 37: return West;
			case 39: return East;
		}
		return null;
	}
	
	public static DirectionEnum getDirectionFromChar(char c){
		switch(c){
			case 'n': return North;
			case 's': return South;
			case 'w': return West;
			case 'e': return East;
		}
		return null;
	}
}
